package com.zhuobowen.warehouse.controller;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.apache.commons.io.IOUtils;
import com.zhuobowen.common.web.core.BaseController;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.InputStream;
import java.nio.charset.StandardCharsets;

@RestController
@RequestMapping("/wms/inventory/resource")
public class InventoryResourceController extends BaseController {

    @GetMapping("/summary/list")
    public JSONArray summaryList(Integer pageNum, Integer pageSize, String goodsName, String customerName) throws Exception {
        ClassPathResource resource = new ClassPathResource("json/wms/inventory_summary.json");
        InputStream inputStream = resource.getInputStream();
        String jsonStr = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
        return JSONUtil.parseArray(jsonStr);
    }

    @GetMapping("/query/list")
    public JSONObject queryList(Integer pageNum, Integer pageSize) throws Exception {
        ClassPathResource resource = new ClassPathResource("json/wms/inventory_query.json");
        InputStream inputStream = resource.getInputStream();
        String jsonStr = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
        return JSONUtil.parseObj(jsonStr);
    }

    @GetMapping("/export-import/list")
    public JSONArray exportImportList(Integer pageNum, Integer pageSize) throws Exception {
        ClassPathResource resource = new ClassPathResource("json/wms/inventory_export_import_summary.json");
        InputStream inputStream = resource.getInputStream();
        String jsonStr = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
        return JSONUtil.parseArray(jsonStr);
    }

}
